package cate.common.table.item.furniture.row;

import cate.common.table.EExcelNoteField;
import cate.common.table.EExcelRowClass;
import cate.common.table.ERow;
import cate.common.table.item.IBagItemTpl;
import cp.solution.util.str.Str;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;


@EExcelRowClass(IDTitle = "手办ID")
public class FurnitureItemBaseRow extends ERow implements IBagItemTpl {
    @EExcelNoteField(fieldName = "手办原型ID")
    public int protoId;
    @EExcelNoteField(fieldName = "品质")
    public byte quality;
    @EExcelNoteField(fieldName = "手办名称备注")
    public String name;
    @EExcelNoteField(fieldName = "手办宽高格子")
    private String sizeStr;
    @EExcelNoteField(fieldName = "套装ID")
    public int suiteId;
    @EExcelNoteField(fieldName = "阵营属性1")
    public int camp1Group;
    @EExcelNoteField(fieldName = "阵营属性2")
    public int camp2Group;
    @EExcelNoteField(fieldName = "通用属性")
    public int commonGroup;
    @EExcelNoteField(fieldName = "职业属性1")
    public int job1Group;
    @EExcelNoteField(fieldName = "职业属性2")
    public int job2Group;
    @EExcelNoteField(fieldName = "职业")
    private String jobRangeStr;
    @EExcelNoteField(fieldName = "阵营")
    private String campRangeStr;
    @EExcelNoteField(fieldName = "手办类型")
    public int type;

    @Override
    public String getName() {
        return name;
    }

    @Override
    public int getTemplateId() {
        return id;
    }

    @Override
    public long getPileMax() {
        return 1;
    }

    @Override
    public boolean unique() {
        return true;
    }

    public List<Byte> camps = new ArrayList<>();
    public List<Byte> jobs = new ArrayList<>();
    public int width = 1;
    public int height = 1;

    @Override
    public void decode() {
        if (StringUtils.isNotBlank(jobRangeStr)) {
            jobs = Str.str2ByteList(jobRangeStr, "#");
        }
        if (StringUtils.isNotBlank(campRangeStr)) {
            camps = Str.str2ByteList(campRangeStr, "#");
        }
        if (StringUtils.isNotBlank(sizeStr)) {
            String[] arr = sizeStr.split(":");
            width = Integer.parseInt(arr[0]);
            height = Integer.parseInt(arr[1]);
        }
    }
}
